<#include 'global.ftl'>
<#macro header title>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <#-- <link rel="shortcut icon" href="../../assets/ico/favicon.ico"> -->
  <title>${title!''}</title>
  <link href="${cssRoot}/demo.css" rel="stylesheet">
  <link rel="stylesheet" href="${cssRoot}/github.min.css">

  <style>
      .form-inline .form-control{ width: auto; margin-left: 4px;}
  </style>
  <#nested>
</head>
<body>
</#macro>

<#macro body navActived sidebar pageHeader>
<#include 'header.ftl'>
<div class="container bs-docs-container">
  <div class="row">
    <div class="col-md-3">
      <div class="bs-sidebar hidden-print affix" role="complementary">
        <ul class="nav bs-sidenav">
          <li>
            <a href="#examples">案例</a>
          </li>
          <li>
            <a href="#usage">用法</a>
          </li>
        </ul>
      </div>
    </div>
    <div class="col-md-9">
      <#nested>
    </div>
  </div>
</div>
</#macro>

<#macro footer>
  <script src="${jsRoot}/jquery-debug.js"></script>
  <script src="${jsRoot}/sea-debug.js"></script>
  <script src="${jsRoot}/seajs-text.js"></script>
  <script src="${jsRoot}/seajs-style.js"></script>
  <script src="${jsRoot}/bootstrap.js"></script>
  <script src="${jsRoot}/highlight.min.js"></script>
  <script id="seajs-config">
    hljs.initHighlightingOnLoad();
    window.GLOBAL = {
      CTX: '${ctx}'
    };
    <#if DEBUG?? && DEBUG>
      seajs.config({
        base: '${ctx}/fed/sea-modules/',
        paths: {
          common: '${ctx}/fed/src/app/common/'
        },
        map: [
          //['${ctx}/sea-modules/jquery', '${jsRoot}/jquery'],
          //[/(\/sea\-modules\/[^(\-debug)]+?)\.js/, '$1-debug.js']
          function(uri) {
            if (!/\-debug\.(js|css)+/g.test(uri) && uri.indexOf('/app/') == -1) {
                uri = uri.replace(/\/(.*)\.(js|css)/g, "/$1-debug.$2")
            }
            return uri
          }
        ],
        alias: {
          '$':          'jquery/jquery/2.1.0/jquery',
          '$-debug':    'jquery/jquery/2.1.0/jquery-debug',
          'jquery':          'jquery/jquery/2.1.0/jquery',
          'jquery-debug':    'jquery/jquery/2.1.0/jquery-debug',
          'alert':      'pandora/dialog/1.0.0/alert',
          'class':      'pandora/class/1.0.0/class',
          'base':      'pandora/base/1.0.0/base',
          'confirm':    'pandora/dialog/1.0.0/confirm',
          'dialog':     'pandora/dialog/1.0.0/dialog',
          'draggable':  'pandora/dragdrop/1.0.0/draggable',
          'locker':     'pandora/locker/1.0.0/locker',
          'select':       'pandora/select/1.0.0/select',
          'moment':     'gallery/moment/2.5.1/moment',
          'prompt':     'pandora/dialog/1.0.0/prompt',
          'styles':     'pandora/styles/1.0.0/styles',
          'tabs':       'pandora/tabs/1.0.0/tabs',
          'tempine':    'pandora/tempine/1.0.0/tempine',
          'timer':      'pandora/timer/1.0.0/timer',
          'tips':       'pandora/dialog/1.0.0/tips',
          'util':       'pandora/util/1.0.0/util',
          'validate':   'pandora/validate/1.0.0/validate',
          'bootstrap3-grid': 'jquery/bootstrap3-grid/0.6.2/bootstrap3-grid',
          'popover': 'jquery/popover/3.1.1/popover',
          'handlebars': 'gallery/handlebars/1.0.2/handlebars',
          'handlebars-helpers': 'gallery/handlebars-helpers/1.3.0/handlebars-helpers',
          "daterangepicker": "jquery/daterangepicker/1.3.8/daterangepicker",
          'ztree': 'gallery/ztree/3.5.15/ztree',
          'widget': 'pandora/widget/1.0.0/widget',
        }
      });
    <#else>
      seajs.config({
        base: '${jsRoot}'
      });
    </#if>
    !function() {
      var deps = [
        '"${appRoot}/common/search/search"',
        '"${appRoot}/common/select/select"',
        '"${appRoot}/common/editor/editor"',
        '"${appRoot}/common/util"',
      ];
      var mods = [
        'Search',
        'Select',
        'Editor',
        'util'
      ];
      deps = deps.join(',');
      mods = mods.join(',');
      var $seaCfg = $('#seajs-config');
      var code = [];
      $('.highlight code').each(function() {
        var html = $(this).html().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
        code.push(html);
      });
      //code = ['use strict', ';', '\n'].concat(code);
      var script = document.createElement('script');
      var text = 'seajs.use([' + deps + '], function(' + mods + ') {\n' +
        code.join('') +
      '\n});';
      //console.log(text)
      script.appendChild(document.createTextNode(text));
      console.log(script)
      $seaCfg.after(script);
    }();

  </script>
  <#nested>

</body>
</html>
</#macro>
